#coding=utf8
'''
Created on 2013-6-17

@author: Administrator
'''

import TestLib 


a = 1
def change_integer(a):
    a = a + 1
    return a

print change_integer(a)
print a



class Animal(object):
    have_further = False
    have_tail = False
    def move(self, dx, dy):
        position = [0, 0]
        position[0] = position[0] + dx
        position[1] = position[1] + dy
        return position
    
summer = Animal()
print summer.have_further
print 'after move:', summer.move(3, 4)

class Cat(Animal):
    ways_of_move = 'walk'

class Dog(Animal):
    ways_of_move = 'walk'

summer = Dog()
print summer.ways_of_move

class Human(object):
    def __init__(self, gender):
        self.gender = gender
    def printGender(self):
        print self.gender

tom = Human('male')
tom.printGender()



print [1, 2, 3] + [4, 5, 6]

class superList(list):
    def __sub__(self, b):
        a = self[:]
        b = b[:]
        while len(b) > 0:
            element_b = b.pop()
            if element_b in a:
                a.remove(element_b)
        return a

print 'AAA:', superList([1, 2, 3]) - superList([3, 4])


tFile = open('./abc.txt')
lines = tFile.readlines()
print lines

for line in lines:
    print line

def func0(a, b, c):
    print 'func0', a, b, c
    
def func1(*name):
    print type(name)
    print name

def func2(**name):
    print type(name)
    print name

args = (1, 2, 3)
func0(*args)

args = {'a':'A', 'b':'B', 'c':'C'}
func0(**args)

func1(1, 2, 3)
func2(a='A', b='B', c='C')

print '======================='

ta = [1, 2, 3]
tb = [9, 8, 7]
tc = ['a', 'b', 'c']
for (a, b, c) in zip(ta, tb, tc):
    print a, b, c

print '======================='
re = map((lambda x: x + 3), [1, 3, 5, 6])
print re

print reduce((lambda x, y: x + y), [1, 2, 5, 7, 9])


print '======================='
re = iter(range(5))

try:
    for i in range(100):
        print re.next()
except StopIteration:
    print 'here is end ', i

print 'HaHaHaHa'


print '======================='

alist = {'a', 'b', 'c'}
atuple = {1, 2, 3,}
astring = 'AString'

print 'len(alist)', len(alist)
print 'len(atuple)', len(atuple)
print 'len(astring)', len(astring)

print 'min(alist)', min(alist)
print 'max(alist)', max(alist)
print 'all(alist)', all(alist)
print 'any(alist)', any(alist)

print 'sum(atuple)', sum(atuple)
print 'astring.index(\'r\')', astring.index('r')
print 'astring.count(\'n\')', astring.count('n')
print 'astring.istitle()', astring.istitle() 

astring = '|hello world|'
anotherstring = 'abc'
print astring.join(anotherstring)

print astring.center(2)
print astring.ljust(2)
print astring.rjust(2)


print '======================='

print TestLib.lib_func(1)


print '======================='

import inspect
print(inspect.getargspec(func0))

print dir(astring)
print astring.__class__
print astring.__class__.__name__
print astring.__class__.__base__

print '你好吗'

print '======================='
import sys
print sys.path

print '======================='
a = "I'm %s. I'm %d year old" % ('abc', 99)
print(a)

print '======================='
class Me(object):
    def test(self):
        print "Hello!"

def new_test():
    print "New Hello!"

me = Me()

print repr(me)


import datetime, time

print time.time()
print time.strftime('%Y-%m-%d %H:%I:%M.%S',time.localtime(time.time()))







